package controllers;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import dto.DTOUser;
import dto.ResourceDTO;
import beans.ResourcesBeanRemote;


/**
 * 
 * @author Zsombor
 *
 */
@ManagedBean
public class ResourceDTOController {

	@EJB
	ResourcesBeanRemote reb;

	@ManagedProperty(value = "#{resource}")
	ResourceDTO reDto;
	
	@ManagedProperty(value="#{dTOUser}")
	private DTOUser currentUser;

	

	public ResourceDTO getReDto() {
		return reDto;
	}

	public void setReDto(ResourceDTO reDto) {
		this.reDto =  reDto;
	}

	public String deleteResource() {
		reb.deleteResource(reDto.getId(),currentUser.getId());
		return "ok";
	}
	
	public String unlockResource(){
		reb.unlockResource(reDto.getId(),currentUser.getId());
		return "ok";
	}
	
	

}